module Page2.Model exposing (..)
import Json.Decode as D

type alias Page =
    { title : String
    , contact : Contact
    , detail : Detail
    }

type alias Contact =
    { title : String
    , phone : String
    , email : String
    , qq : String
    }

type alias Detail = 
    { name : String
    , school : String
    , exp : String
    , github: String
    , gitee: String
    , cnblog: String
    , expect_job: String 
    }

decoder : D.Decoder Page
decoder = 
    D.map3 Page
      (D.field "title" D.string)
      (D.field "contact" contact_decoder)
      (D.field "detail" detail_decoder)

contact_decoder : D.Decoder Contact
contact_decoder =
    D.map4 Contact
      (D.field "title" D.string)
      (D.field "phone" D.string)
      (D.field "email" D.string)
      (D.field "qq" D.string)
      

detail_decoder : D.Decoder Detail
detail_decoder =
    D.map7 Detail
      (D.field "name" D.string)
      (D.field "school" D.string)
      (D.field "exp" D.string)
      (D.field "github" D.string)
      (D.field "gitee" D.string)
      (D.field "cnblog" D.string)
      (D.field "expect_job" D.string)